home *** CD-ROM | disk | FTP | other *** search
-
- editor <filename>
-
- Invoke an internal ASCII text editor. One of two editors was
- selected at compile time. If ED was defined, a line-oriented
- editor, similar to UN*X V7 ed, is invoked. If instead TED was
- defined, a full-screen editor similar to TED2 is invoked.
- Note that <filename> may be too large to process. The editor
- is intended for sysops to edit small configuration files, such
- as ftpusers, forward.bbs, etc.
-
- Ed requires about 13KB for code, and reads files into memory,
- subject to available memory and the 'memory threshold' setting.
- Ed is usable by remote sysops and works over linemode connections.
- Ted needs 5KB of code space and will allocate two 8KB buffers,
- thus the largest file it can process is 8192 bytes long. Ted
- can only be used from the local console.
-
- This file describes both editors, first ED and then TED.
-
- ED:
- As a line editor, ed operates in one of two modes: COMMAND
- mode, in which a colon is displayed at the screen's bottom
- to prompt for a command; and INPUT mode, in which all
- keyboard input is added to the file (edit buffer). From
- COMMAND mode, INPUT mode is entered by either the `i' or `a'
- commands. From INPUT mode, the COMMAND mode is restored by
- entering a line consisting of a single period by itself. If
- such a line is desired in the file, it can be created by
- entering (for instance) two periods, then using the `s'
- command to change these to only one period.
-
- A command consists of an optional line-range specification,
- a single character indicating the command, and for some
- commands an optional third argument. The line-range
- specification is either a single line number or a first-line
- number and a last-line number separated by a comma. The
- character `^' means the first line of the file; `$' means
- the last line of the file.
-
- Commands:
- <newline>
- If a line is specified, make that the new current line.
- Otherwise advance the current-line-pointer by one line.
- = Print the line number of the current line.
- . (by itself) Print the current line.
- - (by itself) Move the current-line-pointer back one, and
- print the new current line.
- + (by itself) Move the current-line-pointer forward one, and
- print the new current line.
- \x (by itself) Go to line marked previously by kx (x in a..z)
- / (followed by search string) Go to next line matching the
- string. See Regular Expressions, below.
- ? (followed by search string) Go to preceding line matching
- the string. See Regular Expressions, below.
- a Go into INPUT mode with a new line following the current
- line. (INPUT mode is terminated by an input line containing
- only a period in the first column.)
- i Go into INPUT mode with a new line preceding the current
- line. (INPUT mode is terminated by an input line containing
- only a period in the first column.)
- c Delete the specified lines (or the current line) and then
- add new lines in their place. This is equivalent to a `d'
- command followed by an `i' command.
- d Delete the specified range of lines (or the current line).
- Leave the current-line-pointer at the following line.
- e Clear the edit buffer and begin editing a new file. This
- command fails if the buffer contains changes (or new lines)
- which have not been written out. To discard these changes
- and edit a new file, use `E' instead of `e'.
- E Clear the edit buffer and begin editing a new file, regardless
- of any changes to the current edit buffer.
- f Print the filename, or set it to a new name if specified.
- g/RE/c Execute an arbitrary ed command "c" on each line in the given
- line range, that matches Regular Expression RE.
- j Join the addressed lines together (or the current line to
- the previous line).
- k Mark the addressed line with the specified letter. Example:
- `17ka' puts mark "a" on line 17. See \ command.
- l List the addressed lines, showing all non-printing characters
- and indicating the end-of-line.
- m Move the specified range of lines to follow the line number
- given. Example: `5,7m3' moves lines 5 through 7 "up", to
- follow line 3.
- p,P Print the specified lines.
- q Quit the editor. This fails if the edit buffer contains
- any changes. If so, use `Q' instead.
- Q Quit the editor absolutely. Any changes are discarded.
- r Read in a file, adding it after the current line.
- s Substitute text on the current line. Example: `s/alp/be/'
- finds the string "alp" and replaces it with "be". The
- first string may contain Regular Expressions, see below.
- If the replacement string contains an '&', the '&' is replaced
- by that portion of the line text that matched the regular
- expression. If a '\d' (d in 1..9) is encountered in the
- replacement string, it is replaced by that portion of the
- line text matched by the d'th pair of parentheses in the
- regular expression.
- The replacement string may be followed by a delimiter and
- two optional flags: "g" to indicate global replacement, ie,
- every occurance is replaced, not just the first, and "p"
- to print the result of the command's operation.
- set [opt]. Displays current options, or sets given option.
- Options are: number show line numbers
- nonumber don't show line numbers (default)
- list show HT as ^i, show $ at end-of-line
- nolist show lines verbatim (default)
- eightbit retain high-order bit in input data
- (default)
- noeightbit strip off high-order bit
- t Transfer (copy) the specified range of lines to follow the
- line number given. Example: `5,7t7' puts a copy of lines
- 5 through 7 after line 7.
- v/RE/c Execute an arbitrary ed command "c" on each line in the given
- line range, that does NOT match Regular Expression RE.
- w,W Write the edit buffer out. If a filename is given, it is
- used and becomes the current filename. If a range of lines
- is specified, only those lines are written.
- x Write the entire buffer out to its file, and terminate.
- z Print a full screen. Variants include:
- z- fill the screen, ending at current line
- z. fill the screen, centered about the current line
- z+ fill the screen, beginning with the current line
-
-
- BUGS and COMMENTS
- Here's an example of how to split a line: .s/BUGS/BU\nGS/
- The backslash n (\n) ends the current line after the U and
- starts another line beginning with G.
-
- Limited arithmetic is possible on line numbers or ranges.
- For example: .,.+10p print current and following 10 lines
- .,+10p same (dot is implicit)
- -5,+5p print 11 lines centered on current line.
- /n5knx/;+5p find next occurance of "n5knx", make
- that the current line, then print it and
- the following 5 lines.
-
-
- REGULAR EXPRESSIONS
- Regular expressions are the extended kind found in grep.
- They are composed of characters as follows:
-
- c matches the non-metacharacter c.
-
- \c matches the literal character c.
-
- . matches any character except newline.
-
- ^ matches the beginning of a line or a string.
-
- $ matches the end of a line or a string.
-
- [abc...] character class, matches any of the characters
- abc.... A range may be specified as x-y.
-
- [^abc...] negated character class, matches any character
- except abc... and newline.
-
- r1|r2 alternation: matches either r1 or r2.
-
- r1r2 concatenation: matches r1, and then r2.
-
- r* matches zero or more r's.
-
- \(r\) grouping: matches r.
-
- The escape sequences that are valid in string constants
- are also legal in regular expressions, e.g., \t for tab.
-
- Example: s/^.*z/X/ Replace all characters through
- the last z with a single X.
- s/[aA][aA]*/&x/g Suffix all sequences of a or A
- chars with an x.
- s/\(j\)\(j*\)\([^;])/\1Z\2\3/g Insert a Z after
- the first j in each sequence of
- j's that is not followed by a
- semicolon.
-
- AUTHORS
- Brian Beattie seems to be the original author. Kees Bot is
- associated with it. Allan Holub authored some bitmap code.
- Andy Tanenbaum ported it to MINIX, and posted it to Usenet.
- Bob Montante ported it to MSDOS and did some minor dressing-up.
- Ed L. did further cleanups, and James Dugal ported it to Jnos
- and made a few more fixes.
-
- ----------------------------------------------------------------------
-
- TED:
- See the article "The tiniest editor you'll ever need" by Tom
- Kihlken, in the November 15, 1988 issue of PC Magazine for
- more detail than is presented here. Portions of this text
- are excerpted from that article. The source listing,
- itself, was copied directly from that article and altered
- as appropriate to add comments or change or improve the
- program. Modifications are by James E. Galbraith, June 1989,
- and adaption to Jnos by James Dugal, Dec 1995.
-
- TED follows normal text conventions: pressing the <Enter>
- key actually adds two characters, Carriage-return (ASCII
- 13) and Line-feed (ASCII 10), also known as a "hard
- carriage return". The <Tab> key inserts the ASCII 9 tab
- character, and advances the screen cursor to the next column
- that is an even multiple of eight. The <Backspace> key
- deletes the character to its immediate left ("destructive"
- backspace) and combines two lines if it is pressed while in
- the first column.
-
- Like DOS, TED lets you enter any character (except <Nul>,
- value 00) by holding down the Alt key, typing the decimal
- value of its ASCII code on the numeric keypad, then
- releasing Alt. This gives you access both to nonprinting
- codes below ASCII 32 and to the upper-order (ASCII 128 to
- 255) characters in the extended IBM set. TED2 allows the
- <Nul> code to be entered by pressing the <Shft-F1> key.
- Unassigned keyboard codes are treated as no-operations.
-
- WARNING: because the Jnos keyboard input routines are used,
- the FKEY command must be used to define any editing key
- before it can be used in TED. A suggested set of fkey
- commands can be found below.
-
- The TED Keypad commands are:
- KEY DESCRIPTION
- Up Arrow Moves cursor up one row
- Down Arrow Moves cursor down one row
- Left Arrow Moves cursor left one column
- Right Arrow Moves cursor right one column
- PgUp Moves text window up one page
- PgDn Moves text window down one page
- Home Moves cursor to start of row
- (if at home, next up)
- End Moves cursor to end of row (if at end,
- next end down)
- Ins Toggles insert/overstrike mode
- Del Deletes character (right) at cursor
- (saved in UnDo)
- Backspace Deletes character (left) at cursor
- (not saved in UnDo)
- Ctrl-PgUp Does a PgUp, then a PgDn.
- Ctrl-Home Moves to top of file.
- Ctrl-PgDn Moves to bottom of file
- Ctrl-End Moves to bottom of file (alias)
- * Ctrl-Right Arrow Moves text window right eight columns
- * Ctrl-Left Arrow Moves text window left eight columns
-
-
- The TED Editing Functions are:
- KEY FUNCTION OPERATION
- F1 Help Help screen
- ShftF1 <Nul> Enters the <Nul> code (value 00)
- in the file
- F2 Exit Save changes and exit (creates a
- .BAK file)
- ShftF2 Quit Exit without saving changes
- F3 Print Prints the marked text
- F4 Mark Toggles mark state on/off
- F5 Cut Moves marked text to paste buffer
- ShftF5 Paste Inserts contents of paste buffer
- (8K chars max)
- F6 Search Search for (case insensitive)
- character string
- ShftF6 Search Again Search again for string
- F7 UnDo Replaces recently DELeted characters
- (256 chars max)
- ShftF7 Udel L Inserts the last deleted line
- (256 chars max)
- F8 Del EOL Deletes from cursor to the end of line
- ShftF8 Del L Deletes the current line
-
- Those marked with * are not directly available under Jnos.
-
- JNOS FKEY USAGE:
- Because the Jnos keyboard handler does not pass key scancodes
- we must make use of the Fkey command to redefine what Function
- and editing keys send. We do this by defining a two-byte
- sequence: SOH and then the upper byte of the scancode (the lower
- byte is zero for all editing and function keys we are interested
- in).
-
- # Source this file to program the console keys for the TED editor
- # Do F1 to F8
- fkey 59 "\001\073"
- fkey 60 "\001\074"
- fkey 61 "\001\075"
- fkey 62 "\001\076"
- fkey 63 "\001\077"
- fkey 64 "\001\100"
- fkey 65 "\001\101"
- fkey 66 "\001\102"
- # Now define Home,Up,PgUp,Left,Right,End,Down,PgDn,Ins,Del
- fkey 71 "\001\107"
- fkey 72 "\001\110" *
- fkey 73 "\001\111"
- fkey 75 "\001\113" *
- fkey 77 "\001\115" *
- fkey 79 "\001\117"
- fkey 80 "\001\120" *
- fkey 81 "\001\121"
- fkey 82 "\001\122"
- fkey 83 "\001\123"
- # Now Shifted F1..F3, F5..F8
- fkey 84 "\001\124"
- fkey 85 "\001\125"
- fkey 86 "\001\126"
- fkey 88 "\001\130"
- fkey 89 "\001\131"
- fkey 90 "\001\132"
- fkey 91 "\001\133"
- # Now do Control- Left,Right,End,PgDn,Home,PgUp
- #fkey 115 "\001\163"
- #fkey 116 "\001\164"
- fkey 117 "\001\165"
- fkey 118 "\001\166"
- fkey 119 "\001\167"
- fkey 132 "\001\204"
- # Let's use CF11,CF12 as Control-Left, Control-Right so we don't have to
- # add new scancodes to the Jnos array in pc.c.
- fkey 137 "\001\163"
- fkey 138 "\001\164"
- # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- # The 4 cursor key redefinitions, marked with * above, will break telnet's
- # cursor key ansi emulation. An alternative is to comment out the 4
- # redefinitons above, and use home/end to move vertically, and use F11/F12
- # as cursor left/right (which we now define):
- fkey 133 "\001\113"
- fkey 134 "\001\115"
-
-